namespace ICSharpCode.TextEditor.Document
{
    public class ColumnRange
    {
        public static readonly ColumnRange NoColumn = new ColumnRange(-2, -2, isCurrent: false);

        public static readonly ColumnRange WholeColumn = new ColumnRange(-1, -1, isCurrent: true);

        public static readonly ColumnRange NewLineColumn = new ColumnRange(0, 0, isCurrent: true);

        private int startColumn;

        private int endColumn;

        private bool isCurrent;

        public int StartColumn
        {
            get
            {
                return startColumn;
            }
            set
            {
                startColumn = value;
            }
        }

        public int EndColumn
        {
            get
            {
                return endColumn;
            }
            set
            {
                endColumn = value;
            }
        }

        public bool IsCurrent
        {
            get
            {
                return isCurrent;
            }
            set
            {
                isCurrent = value;
            }
        }

        public ColumnRange(int startColumn, int endColumn)
        {
            isCurrent = false;
            this.startColumn = startColumn;
            this.endColumn = endColumn;
        }

        public ColumnRange(int startColumn, int endColumn, bool isCurrent)
        {
            this.isCurrent = isCurrent;
            this.startColumn = startColumn;
            this.endColumn = endColumn;
        }

        public override int GetHashCode()
        {
            return checked(startColumn + (endColumn << 16));
        }

        public override bool Equals(object obj)
        {
            if (obj is ColumnRange)
            {
                return ((ColumnRange)obj).startColumn == startColumn && ((ColumnRange)obj).endColumn == endColumn;
            }
            return false;
        }

        public override string ToString()
        {
            return $"[ColumnRange: StartColumn={startColumn}, EndColumn={endColumn}]";
        }
    }
}
